﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Data;
using System.Data.SqlClient;
using DataAccess.SqlClient;
using Model;
namespace DAL
{
   public class ImagesDAL
    {
       /// <summary>
       /// 图片类型表
       /// </summary>
       /// <returns></returns>
       public static dynamic ImagesTypeshow()
       {
           var q = new SqlQuery
           {
               CommandText = "select ImagesTID,InTypes from ImagesType",
           };
           var dt = SqlDataAccess.ExecDataset(q).Tables[0];//连接数据库，获取图片类型表
           var list = new List<dynamic>();
           foreach (var dr in dt.Select())
           {
               list.Add(

                   new
                   {
                       ImagesTID = dr.Field<Guid>("ImagesTID"),
                       InTypes = dr.Field<string>("InTypes"),
                   }
                   );
           }
           return list;
       }

       /// <summary>
       /// 图片表
       /// </summary>
       /// <returns></returns>
       public static dynamic Imagesshow()
       {
           var q = new SqlQuery
           {
               CommandText = "select a.*,b.InTypes from Images a inner join ImagesType b on a.ImagesTID=b.ImagesTID",
           };
           var dt = SqlDataAccess.ExecDataset(q).Tables[0];//连接数据库，获取图片表
           var list = new List<dynamic>();
           foreach (var dr in dt.Select())
           {
               list.Add(

                   new
                   {
                       ImagesID = dr.Field<Guid>("ImagesID"),
                       Url = dr.Field<string>("Url"),
                       ImagesTID = dr.Field<Guid>("ImagesTID"),
                       InTypes = dr.Field<string>("InTypes"),
                   }
                   );
           }
           return list;
       }
    }
}
